using System;
using System.Collections;

namespace NGNntpPlugIn
{
	/// <summary>
	/// Summary description for NntpServerCollection.
	/// </summary>
	public class NntpServerCollection : IList
	{
		ArrayList m_nntpServers;

		public NntpServerCollection()
		{
			m_nntpServers = new ArrayList();
		}

		#region IList Members

		public bool IsReadOnly
		{
			get
			{
				return m_nntpServers.IsReadOnly;
			}
		}

		public object this[int index]
		{
			get
			{
				return m_nntpServers[index];
			}
			set
			{
				m_nntpServers[index] = value;
			}
		}

		public void RemoveAt(int index)
		{
			m_nntpServers.RemoveAt(index);
		}

		public void Insert(int index, object value)
		{
			m_nntpServers.Insert(index, value);
		}

		public void Remove(object value)
		{
			m_nntpServers.Remove(value);
		}

		public bool Contains(object value)
		{
			return m_nntpServers.Contains(value);
		}

		public bool Contains(string serverAddress)
		{
			bool found = false;

			foreach(NntpServer server in m_nntpServers)
			{
				if(server.Server.ToLower() == serverAddress.ToLower())
				{
					found = true;
					break;
				}
			}

			return found;
		}

		public void Clear()
		{
			m_nntpServers.Clear();
		}

		public int IndexOf(object value)
		{
			return m_nntpServers.IndexOf(value);
		}

		public int IndexOf(string serverName)
		{
			int index = -1;

			for(int i=0; i<m_nntpServers.Count; i++)
			{
				if(((NntpServer) m_nntpServers[i]).Server.ToLower() == serverName.ToLower())
				{
					index = i;
					break;
				}
			}

			return index;
		}

		public int Add(object value)
		{
			return m_nntpServers.Add(value);
		}

		public bool IsFixedSize
		{
			get
			{
				return m_nntpServers.IsFixedSize;
			}
		}

		#endregion

		#region ICollection Members

		public bool IsSynchronized
		{
			get
			{
				return m_nntpServers.IsSynchronized;
			}
		}

		public int Count
		{
			get
			{
				return m_nntpServers.Count;
			}
		}

		public void CopyTo(Array array, int index)
		{
			m_nntpServers.CopyTo(array, index);
		}

		public object SyncRoot
		{
			get
			{
				return m_nntpServers.SyncRoot;
			}
		}

		#endregion

		#region IEnumerable Members

		public IEnumerator GetEnumerator()
		{
			return m_nntpServers.GetEnumerator();
		}

		#endregion
	}
}
